package com.training.java.core.collections.map;

import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import java.util.Map.Entry;

public class HashMapStudentNames {

	public static void main(String[] args) {

		Map<String, String> studentName = new HashMap<String, String>();

		studentName.put("Raji", "Grapes");
		studentName.put("Siva", "Apple");
		studentName.put("Satya", "Strawberry");
		studentName.put("Peng", "Kiwi");
		studentName.put("Henry", "Orange");
		studentName.put("Almas", "Mango");
		studentName.put("Ronnie", "Watermelon");
		studentName.put("Binod", "Banana");

		// Method 1 to get keys and values
		Set<String> keySet = studentName.keySet();

		for (String aKey : keySet) {
			System.out.println("A key = " + aKey);

			String favoriteFruit = studentName.get(aKey);
			System.out.println("A  Favorite Fruit = " + favoriteFruit);

		}
		System.out.println("***********************");
		// Method 2 to get keys and values
		Set<Entry<String, String>> entrySet = studentName.entrySet();
		for (Entry<String, String> eachEntry : entrySet) {
			System.out.println("Key = " + eachEntry.getKey());
			System.out.println("Favorite Fruit = " + eachEntry.getValue());
		}

		System.out.println("************************************");
		String favoriteFruit = studentName.get("studentName");
		System.out.println("FavoriteFruit = " + studentName);

		System.out.println("***********************************");

		System.out.println("studentName = " + studentName.get(favoriteFruit));
		
		System.out.println("***********************************");
		String rajisFruit = studentName.get("Raji");
		System.out.println("Raji's favorite fruit  = " + rajisFruit);


	}
}
